<?php if( !defined( 'MAIN_DIR' ) ) { header( 'Location: ' . dirname( PHP_SELF ) . '/' ); exit( ); }
	$LANG = ( isset( $LANG ) && $LANG ? $LANG : null );
	$file = ( isset( $file ) && $file ? $file : null );

	$mainFile = new File( );
	if( $file->getIdFile( ) == 1 )
		$mainFile = $file;
	else if( !$mainFile->load( 1 ) )
		finalError( ' 1. ' . $LANG['E']['MAIN_FILE'] );
	
	function toTree( $tfile, $neighbor = false )	{
		global $file;
		
		if( MIT )
			$files = $tfile->getChilds( );
		else
			$files = $tfile->getAllFiles( FOLDER_TYPES, 0, true );
		
		$max = count( $files );
?>
	<table summary="" id="opt_<?php echo $tfile->getIdFile( ) ?>" width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
<?php
		if( $tfile->getIdFile( ) > 1 )	{
			$img = 'tree' . ( $neighbor ? '_neighbor' : '' ) . ( $max > 0 ? '_colapsed' : '' );
			
?>
		<td width="17" height="17" onclick="treeClick(<?php echo $tfile->getIdFile( ) ?>)"><img src="images/<?php echo $img ?>.gif" id="<?php echo 'tree_' . $tfile->getIdFile( ) ?>" width="17" height="17" border="0" alt=""/></td>
<?php
		}
?>
		<td width="16" height="16"><a href="?file_id=<?php echo $tfile->getIdFile( ) ?>"><?php echo toImage( $tfile, 'img_' . $tfile->getIdFile( ) ) ?></a></td>
		<td style="padding-left:4px;"><a href="?file_id=<?php echo $tfile->getIdFile( ) ?>"><?php echo $tfile->getName( ) ?></a></td>
	</tr>
	</table>
	<div id="holder_<?php echo $tfile->getIdFile( ) ?>" style="padding-left:<?php echo ( $tfile->getIdFile( ) > 1 ? 15 : 0 ) ?>px; display: <?php echo ( $tfile->getIdFile( ) == 1 ? 'block' : 'none' ) ?>">
<?php

		for( $c = 0; $c < $max; $c ++ )
			toTree( $files[$c], $c < ( $max - 1 ) );
?>
	</div>
<?php
	}
		
?><div id="treeHolder" style="background-image:url(images/swat.png); background-position: left bottom; background-repeat: no-repeat;">
<?php toTitle( '<img src="images/tree.png" width="16" height="16" border="0" title="Tree" alt="Tree"/>&nbsp;<b>Tree Navegation</b>' ) ?>
	<div id="treeDataHolder">
<?php
	if( MIT )
		$mainFile->setChilds( $mainFile->getAllFiles( FOLDER_TYPES, 0, true, true, false, true ) );
	toTree( $mainFile );
	unset( $mainFile );
?>
	</div>
</div>